home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / tc_tsr10.zip / PRTSC.TXT < prev    next >
Text File  |  1991-06-18  |  4KB  |  92 lines

  1. TsrPrtSc.C, PrtSc.C, PrtSc.H
  2.  
  3. Here is some documentation I wrote some time ago. Hope it's useful, but,
  4.  
  5.      The author shall not be liable to the user for any direct, indirect or
  6.      consequential loss arising from the use of, or inability to use, any
  7.      program or file howsoever caused. No warranty is given that the programs
  8.      will work under all circumstances.
  9.  
  10. Sherif
  11.  
  12. /*--------------------------------------------------------------------------*
  13.  | Sherif El-Kassas        .       :.                                       |
  14.  | EB dept           \_____o__/ __________                                  |
  15.  | Eindhoven U of Tec       .. /                                            |
  16.  | The Netherlands            /             Email: elkassas@eb.ele.tue.nl   |
  17.  *--------------------------------------------------------------------------*/
  18.  
  19. A PRINT SCREEN UTILITY
  20.  
  21. One of the annoying things about printing screens, is that you always get a
  22. copy of the whole screen including things you don't want to print, such as
  23. your word processor's status line, the DOS prompt, ...etc.
  24.  
  25. PrtSc is a memory resident utility - written in Turbo C - that enables you to
  26. select the screen area you really want to print.
  27.  
  28. PREPARING PrtSC
  29.  
  30. Compile using:
  31.  
  32.      C> TCC -mt PrtSc.C TsrPrtSc.C
  33.  
  34. Then type PrtSc and press enter to load the program into your computer's
  35. memory.
  36.  
  37.  
  38. USING PrtSc
  39.  
  40. When you want to call PrtSc press the ALT and PrtSc keys [actually the '*' key
  41. on the right keypad] simultaneously, a white block style cursor will appear at
  42. the upper left corner of the screen.
  43.  
  44. Use the arrow and cursor movement keys to move the cursor to the beginning of
  45. the screen area you want to print and press enter.  Move the cursor to the end
  46. of the block to be printed (a rubber band box will appear as you move around
  47. to help you identify the area to be printed ) and press the enter key once
  48. more. The block enclosed by the rubber band is the printer.
  49.  
  50.  
  51. HOW PrtSc WORKS
  52.  
  53. o INSTALLING IN MEMORY
  54.  
  55. When you run PrtSc it will first initialize some internal variables and system
  56. pointers and then it simply terminates and returns control back to DOS,
  57. however it returns control to DOS using a special DOS function, interrupt 0x21
  58. function 0x31 KEEP PROCESS (we could also use interrupt 0x27 TERMINATE BUT
  59. STAY RESIDENT). Function 0x31 instructs DOS to terminate the current process
  60. but without reallocating it's memory. Therefor the terminated program has
  61. become a part of DOS.
  62.  
  63.  
  64. o POPPING UP
  65.  
  66. Making the program memory resident is not enough, the resident program must be
  67. able to regain control. In our case this is done by checking all the incoming
  68. key strokes until a special key combination is pressed (ALT-PrtSc) to trigger
  69. program action. Checking the incoming key strokes is done by taking over the
  70. keyboard interrupt.
  71.  
  72. One of the problems we face here is that the DOS services provided throw
  73. interrupt 0x21 are not re-entrant, which means that we can't use any DOS
  74. functions (file I/O ..etc) from within the resident program unless we are sure
  75. that DOS is inactive. As it happens DOS maintains a special flag (the BUSY
  76. FLAG) that indicates whether or not a DOS routine is currently active. So
  77. before popping up, the resident utility should check the BUSY FLAG to make
  78. sure that it's safe to use DOS functions. Another undocumented DOS feature is
  79. interrupt 0x28. Interrupt 0x28 is called from DOS functions (e.g when function
  80. 0x0A is waiting for a key stoke) and the interesting thing is that during a
  81. call to interrupt 0x28 it is safe to use DOS functions higher than 0x0C.
  82.  
  83. So PrtSc monitors the keyboard until the ALT and PrtSc keys are pressed, if
  84. DOS is inactive the program is activated otherwise it waits for a call to
  85. interrupt 0x28.
  86.  
  87. [    Note: this program performs direct video access without attempting to
  88.      synchronize with vertical/horizontal retrace. So if you have a CGA you
  89.      will probably get lots of snow. I think the simplest way to fix this is
  90.      to use the screen access routines found in conio.h (this program was
  91.      first written using an pre conio.h version of Turbo C).
  92. ]